package com.wmh.baseservice.robot.entity;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author 青石
 * 对于机器人 请求响应的封装
 */
@Data
@Accessors(chain = true)
public class RobotRes<T> implements Serializable {
    static final long serialVersionUID = 42L;

    @ApiModelProperty(value = "响应码")
    private Integer code;

    @ApiModelProperty(value = "消息")
    private String message;

    @ApiModelProperty(value = "响应体(数据)")
    private T data;

    public final static int OK_CODE = 200;

    public static boolean isError(RobotRes res){
        return res == null || ! Objects.equals(OK_CODE,res.getCode());
    }

    public static boolean isSuccess(RobotRes res){
        return res != null || Objects.equals(OK_CODE,res.getCode());
    }
}
